import UserModel from '../model/systemUser';

export async function AddUser(id: number, username: string, nickname: string, password: string) {
  let data: any = { nickname, username, id, password, status: 1 };

  const model = await UserModel.findOneByName(username);
  if (model) {
      await UserModel.update(data, id);
      // UserLogs('编辑用户', JSON.stringify(data), uuid2, 0, uuid);
  } else {
      const model2 = await UserModel.insert(data);
      // UserLogs('新增用户', JSON.stringify(data), model2.uuid, 0, uuid);
  }
}

export async function GetUser(id: number) {
  return UserModel.findOne(id);
}

export async function GetUserByName(userName: string) {
  return UserModel.findOneByName(userName);
}

export async function GetUserList(pageindex: string | undefined, userName) {
  return UserModel.getlist(Number(pageindex || 1), userName);
}

export async function UpdateUser(data: any, id) {
  // let data: any = { appointDate, appointTime, touristInfo, touristNum, platform };
  const model2 = await UserModel.update(data, id);
}

// export async function DeleteUserList(ids: string[], uuid: string) {
//   if (ids.length === 0) return;
//   await UserModel.delList(ids);
//     // UserLogs('删除用户', '', ids.join(), 1, uuid);
// }
